//
// Created by Admin on 2021/9/20.
//

#include "entry.h"

void student_rank_by_No(pStudent students, int student_count, int subject_count){
    for(int i=0;i<student_count;i++){
        if (students[i].total_score==0){
            calc_student_total(students,student_count,subject_count);
            break;
        }
    }
    int *visited = calloc(student_count,sizeof(int));
    printf("按照学号排名输出总分表：\n");
    for(int i=0;i<student_count;i++){
        int mini_no = 0x7FFFFFFF;
        int mini_pos = -1;
        for(int j=0;j<student_count;j++){
            if(visited[j]==0 && students[j].number < mini_no){
                mini_no = students[j].number;
                mini_pos = j;
            }
        }
        visited[mini_pos] = 1;
        printf("\t学号：%d 学生：%s 总分：%d\n",students[mini_pos].number,students[mini_pos].name,students[mini_pos].total_score);
    }
    free(visited);
}